package kr.pe.johnkim.chattingday.mobile.rest.service;

import kr.pe.johnkim.chattingday.mobile.domain.ChattingDayGatheringJoiner;
import kr.pe.johnkim.chattingday.mobile.domain.ChattingDayMember;
import kr.pe.johnkim.chattingday.mobile.rest.dao.ChattingDayGatheringJoinerDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author : johnkim <cale9797@gmail.com / Bettersoft Inc,.>
 * @Date : 12. 6. 7
 */
public class ChattingDayGatheringJoinerServiceImpl implements ChattingDayGatheringJoinerService {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(ChattingDayGatheringJoinerServiceImpl.class);

    @Autowired
    private ChattingDayGatheringJoinerDao chattingDayGatheringJoinerDao = null;

    /**
     * 채팅방에 참여 한다.
     *
     * @param chattingDayGatheringJoiner
     * @return
     */
    @Override
    public boolean registerGatheringJoiner(ChattingDayGatheringJoiner chattingDayGatheringJoiner) {
        logger.info("registerGatheringJoiner");

        return chattingDayGatheringJoinerDao.registerGatheringJoiner(chattingDayGatheringJoiner);
    }

    /**
     * 채팅방에서 나온다.
     * <p/>
     * 나 자신을 채팅방에서 비활성화 처리 한다.
     *
     * @param chattingDayGatheringJoiner
     * @return
     */
    @Override
    public boolean updateDeactivateGatheringJoiner(ChattingDayGatheringJoiner chattingDayGatheringJoiner) {
        logger.info("updateDeactivateGatheringJoiner");

        return chattingDayGatheringJoinerDao.updateDeactivateGatheringJoiner(chattingDayGatheringJoiner);
    }

    /**
     * 채팅방의 모든 사용자들을 비활성와 처리 한다.
     *
     * @param chattingDayGatheringJoiner
     * @return
     */
    @Override
    public boolean updateDeactivateAllGatheringJoiner(ChattingDayGatheringJoiner chattingDayGatheringJoiner) {
        logger.info("updateDeactivateAllGatheringJoiner");

        return chattingDayGatheringJoinerDao.updateDeactivateAllGatheringJoiner(chattingDayGatheringJoiner);
    }

    /**
     * C2DM 메시지 발송을 위해서 채팅방 참여자들의 REGISTRATION ID 목록을 가져 온다.
     *
     * @param chattingDayGatheringJoiner
     * @return
     */
    @Override
    public List<ChattingDayMember> selectRegistrationIdList(ChattingDayGatheringJoiner chattingDayGatheringJoiner) {
        logger.info("selectRegistrationIdList");

        return chattingDayGatheringJoinerDao.selectRegistrationIdList(chattingDayGatheringJoiner);
    }
}
